<template>
	<view class="content">
		<view class="user-top-box">
			<!-- <image class="user-top-bg" src="/static/img/user-top-bg.png"></image> -->
			<view class="user-top-bg">
				<image class="useTopBg" src="@/static/img/useTopBg.png"></image>
			</view>
			<view class="user-top-cont">
				<image class="touxiang" :src="userInfo.avatar?userInfo.avatar:'@/static/img/user-mr.png'"></image>
				<view class="top-cont-tit">
					<view class="title1">{{userInfo.userName||'用户11231'}}</view>
					<view class="title2">
						<image class="tongqian" src="@/static/img/tongqian.png"></image>
						<text>{{userInfo.balance||0}}</text>
					</view>
				</view>
			</view>
		</view>
		<view class="cont-box">
			<view class="card-box">
				<view class="card-title">
					<view class="card-title-zs"></view>
					<text>我的服务</text>
				</view>
				<view class="icon-box">
					<view class="item-box" v-for="(item,index) in tabList" :key="index" @click="bindPath(item.path)">
						<image class="icon" :src="item.icon"></image>
						<view>{{item.name}}</view>
					</view>
				</view>
			</view>
			<view class="card-box mar-t30">
				<view class="card-title">
					<view class="card-title-zs"></view>
					<text>平台服务</text>
				</view>
				<view class="icon-box">
					<view class="item-box" v-for="(item,index) in tabList2" :key="index" @click="bindPath(item.path)">
						<image class="icon" :src="item.icon"></image>
						<view>{{item.name}}</view>
					</view>
				</view>
			</view>
		</view>



		<tabbar :expertType="2" background="#BA9595"></tabbar>
	</view>
</template>

<script>
	import tabbar from '../components/tabbar.vue';
	import {
		getUserInfo,
	} from '@/api/common'
	import {
		baseURL
	} from "@/api/config.js";
	export default {
		data() {
			return {
				tabList: [{
						icon: require('@/static/img/user1.png'),
						name: '个人资料',
						path: '/pages/user/userInfo'
					},
					{
						icon: require('@/static/img/user2.png'),
						name: '铜币兑换'
					},
					{
						icon: require('@/static/img/user3.png'),
						name: '打卡记录',
						path: '/pages/two/dakaList'
					},
				],
				tabList2: [{
						icon: require('@/static/img/user4.png'),
						name: '服务热线',
						path: '/pages/user/serviceHotline'
					},
					{
						icon: require('@/static/img/user5.png'),
						name: '常见问题',
						path: '/pages/user/question'
					},
					{
						icon: require('@/static/img/user6.png'),
						name: '意见反馈',
						path: '/pages/user/feedback'
					},
					{
						icon: require('@/static/img/user7.png'),
						name: '游客须知',
						path: '/pages/user/visitorNotice'
					},
				],
				userInfo: {},
			}
		},
		components: {
			tabbar
		},

		onLoad(option) {
			if (wx.hideHomeButton) {
				wx.hideHomeButton();
			}
		},
		onShow() {
			if (uni.getStorageSync('userInfo')) {
				let info = uni.getStorageSync('userInfo')
				this.$nextTick(() => {
					this.initUserInfo(info.id)
				})
			}

		},

		methods: {
			async initUserInfo(id) {
				let res = await getUserInfo(id)
				if (res.code == 200) {
					this.userInfo = res.data

				}
			},

			goHome() {
				uni.switchTab({
					url: '/pages/index/index'
				})
			},
			bindPath(path) {
				uni.navigateTo({
					url: path
				})
			},





		}
	}
</script>

<style lang="less" scoped>
	.content {
		height: 100vh;
		overflow-y: auto;
		box-sizing: border-box;
		background: #F6F1E5;
	}

	.user-top-box {
		position: relative;

		.user-top-bg {
			width: 750rpx;
			height: 396rpx;
			margin-top: -140rpx;
			display: block;
			position: relative;
			background: #652605;

			.useTopBg {
				width: 356rpx;
				height: 244rpx;
				position: absolute;
				right: 0;
				bottom: 0;
			}

		}

		.user-top-cont {
			position: absolute;
			left: 0;
			right: 0;
			top: 0;
			padding-left: 52rpx;
			display: flex;
			align-items: center;
			padding-top: 180rpx;

			.touxiang {
				width: 136rpx;
				height: 136rpx;
				border-radius: 50%;
				flex-shrink: 0;
			}

			.top-cont-tit {
				padding-left: 34rpx;

				.title1 {
					font-family: SF Pro Display, SF Pro Display;
					font-weight: bold;
					font-size: 32rpx;
					color: #FFFFFF;
				}

				.title2 {
					margin-top: 26rpx;
					display: flex;
					align-items: center;
					font-family: SF Pro Display, SF Pro Display;
					font-weight: 400;
					font-size: 26rpx;
					color: #FFFFFF;

					.tongqian {
						width: 32rpx;
						height: 32rpx;
						margin-right: 12rpx;
					}
				}
			}
		}
	}

	.cont-box {
		padding: 0 30rpx;
		margin-top: -40rpx;
		position: relative;
		z-index: 2;

		.card-box {
			background: #FFFFFF;
			border-radius: 20rpx;
			padding: 30rpx;

			.card-title {
				display: flex;
				align-items: center;
				font-family: SF Pro Display, SF Pro Display;
				font-weight: bold;
				font-size: 28rpx;
				color: #4C604E;

				.card-title-zs {
					width: 6rpx;
					height: 24rpx;
					background: linear-gradient(180deg, #9DC6A1 0%, #4C604E 100%);
					border-radius: 120rpx 120rpx 120rpx 120rpx;
					margin-right: 10rpx;
				}
			}

			.icon-box {
				padding-left: 12rpx;
				padding-top: 40rpx;
				padding-bottom: 22rpx;

				.item-box {
					display: inline-flex;
					flex-direction: column;
					align-items: center;
					width: 108rpx;
					margin-right: 58rpx;
					font-family: SF Pro Display, SF Pro Display;
					font-weight: 400;
					font-size: 26rpx;
					color: #4C604E;

					.icon {
						width: 108rpx;
						height: 108rpx;
						margin-bottom: 24rpx;
						display: block;

					}
				}

				.item-box:nth-child(4n) {
					margin-right: 0;
				}
			}
		}
	}
</style>